class Rect{
    private double length;
    private double width;

    public Rect(double length, double width) {
        this.length = length;
        this.width = width;
    }

    public double getLength() {
        return length;
    }

    public double getWidth() {
        return width;
    }

    public void setLength(double length) {
        this.length = length;
    }

    public void setWidth(double width) {
        this.width = width;
    }

    public double area(double length, double width){
        return length*width;
    }
    public  double perimeter(double length,double width){
        return  (length+width) * 2;
    }
}
class PlainRect extends Rect {
    private double startX;
    private double startY;


    public double getStartX() {
        return startX;
    }

    public double getStartY() {
        return startY;
    }

    public PlainRect(double length, double width, double startX, double startY) {
        super(length, width);
        this.startX = startX;
        this.startY = startY;
    }

    public PlainRect() {
        super(0, 0);
        this.startX = 0;
        this.startY = 0;
    }


    /**
     * 在x,y坐标轴中，长度范围：startX -- startX+getLength();
     * 宽度的范围：h -- startY;
     *
     * @param x
     * @param y
     * @return
     */
    public boolean islnside(double x, double y) {
        double h = 0;
        double l = startX + getLength();
        if (getStartY() == getWidth()) {//当width == startY,时h = 0;
            h = 0;
        } else if (getStartY() > getWidth()) {//width < startY,在y轴的正半轴， h = width
            h = getWidth();
        } else {                           //width >startY,在y轴的负半轴，h = startY - width;
            h = getStartY() - getWidth();
        }
        return x > startX && x < l && y > h && y < getStartY();
    }
}


public class Test3{
    public static void main(String[] args) {
        PlainRect r1 = new PlainRect(20,10,10,10);
        System.out.println("r1的面积"+r1.area(20,10));
        System.out.println("r1的周长"+r1.perimeter(20, 10));
        PlainRect r2 = new PlainRect();
        System.out.println(r1.islnside(25.5, 13.5));

    }

}
